package org.jwos.platform.desktop.web;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.jwos.platform.service.SessionManager;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class SessionListener implements HttpSessionListener {
	
	public void sessionCreated(HttpSessionEvent event) {		
	}

	public void sessionDestroyed(HttpSessionEvent event) {
		WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(event.getSession().getServletContext());
		SessionManager sessionManager = (SessionManager)context.getBean("sessionManager");
		sessionManager.unregisterSession(event.getSession().getId());
	}
}
